#ifndef GAME_HPP
#define GAME_HPP

#include <QWidget>
#include <QString>
#include <QLabel>

#include "lobby.hpp"
#include "client.hpp"
#include "goban.hpp"

class Lobby;
class Client;
class Goban;

class Game : public QObject
{
    Q_OBJECT

private:
    Lobby * _lobby;
    Client * _client;
    Goban * _goban;

    quint8 _id;
    quint8 _gobanSize;
    qreal _komi;

    bool _isStarted;
    bool _isEstablishingScore;
    bool _isFinished;

    bool _blackToPlay;

    QString _black;
    QString _white;
    QStringList _observers;

    qreal _blackScore;
    qreal _whiteScore;

public:
    Game(Lobby * lobby, Client * client, quint8 id, quint8 gobanSize, qreal komi, const QString & black, QObject * parent = 0);
    Game(Lobby * lobby, Client * client, quint8 id, quint8 gobanSize, qreal komi, const QString & black, const QString & white, QObject * parent = 0);

    quint8 id() const;
    QString black() const;
    QString white() const;
    int komi() const;
    QStringList observers() const;
    bool isStarted() const;
    bool isEstablishingScore() const;
    bool isFinished() const;
    int size() const;

    Goban * goban() const;

    void setState(const QStringList & observerList, const QVector < QVector<quint8> > & map);
    void setObservers(const QStringList & observerList);

    bool blackToPlay() const;
    void switchBlackToPlay();

    void setEstablishingScore(bool isEstablishingScore);

signals:
    void updatePlayer(); // To update the display of this game


public slots:
    void addPlayer(const QString & name);
    void addObserver(const QString & name);

    void removeObserver(const QString & name);
    void clearObservers();
    void destroy();
};


#endif // GAME_HPP
